import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './login/login.component';
import { IndexComponent } from './main/index/index.component';
import { MainComponent } from './main/main.component';
import { PasswordComponent } from './main/password/password.component';
import { LiveLibComponent } from './main/live-lib/live-lib.component';
import { VodLibComponent } from './main/vod-lib/vod-lib.component';
import { OnlinePayComponent } from './main/online-pay/online-pay.component';
import { OfflinePayComponent } from './main/offline-pay/offline-pay.component';
import { RechargeComponent } from './main/recharge/recharge.component';
import { PayLogComponent } from './main/pay-log/pay-log.component';
import { SecurityComponent } from './main/security/security.component';
import { ProfileComponent } from './main/profile/profile.component';
import { RealAuthComponent } from './main/real-auth/real-auth.component';
import { WorkOrderComponent } from './main/work-order/work-order.component';
import { AddComponent as WorkOrderAddComponent } from './main/work-order/add/add.component';
import { OfflinePayLogComponent } from './main/offline-pay-log/offline-pay-log.component';
import { OnlinePayLogComponent } from './main/online-pay-log/online-pay-log.component';
import { VodPubComponent } from './main/vod-pub/vod-pub.component';
import { RefuseWordsComponent } from './main/refuse-words/refuse-words.component';
import { PageEditorComponent } from './main/page-editor/page-editor.component';
import { PageEditorDetailComponent } from './main/page-editor/page-editor-detail/page-editor-detail.component';
import { VodCategoryComponent } from './main/vod-category/vod-category.component';
import { AccountComponent } from './main/account/account.component';
import { UserComponent } from './main/user/user.component';
import { WorkComponent } from './main/work/work.component';
import { VodComponent } from './main/vod/vod.component';
import { LiveComponent } from './main/live/live.component';
import { LiveDetailComponent } from './main/live-detail/live-detail.component';
import { CollectPlatformComponent } from './main/collect-platform/collect-platform.component';
import { TimeDetailComponent } from './main/time-detail/time-detail.component';

const routes: Routes = [
  { path: 'login', component: LoginComponent },
  {
    path: 'main',
    component: MainComponent,
    children: [
      { path: 'index', component: IndexComponent },
      {
        path: 'live', component: LiveComponent, children: [
          { path: 'lib', component: LiveLibComponent },
          { path: 'detail/:id', component: LiveDetailComponent },
          { path: '', redirectTo: '/main/live/lib', pathMatch: 'full' }
        ]
      },
      {
        path: 'vod', component: VodComponent, children: [
          { path: 'lib/:id', component: VodLibComponent },
          { path: 'category', component: VodCategoryComponent },
          { path: 'pub', component: VodPubComponent },
          { path: '', redirectTo: '/main/vod/category', pathMatch: 'full' }
        ]
      },
      {
        path: 'account', component: AccountComponent, children: [
          { path: 'online-pay', component: OnlinePayComponent },
          { path: 'online-pay-log', component: OnlinePayLogComponent },
          { path: 'offline-pay', component: OfflinePayComponent },
          { path: 'offline-pay-log', component: OfflinePayLogComponent },
          { path: 'recharge', component: RechargeComponent },
          { path: 'pay-log', component: PayLogComponent },
          { path: 'time-detail', component: TimeDetailComponent },
          { path: '', redirectTo: '/main/account/offline-pay', pathMatch: 'full' }
        ]
      },
      {
        path: 'user', component: UserComponent, children: [
          { path: 'security', component: SecurityComponent },
          { path: 'profile', component: ProfileComponent },
          { path: 'password', component: PasswordComponent },
          { path: 'real-auth', component: RealAuthComponent },
          { path: 'refuse-words', component: RefuseWordsComponent },
          { path: '', redirectTo: '/main/user/security', pathMatch: 'full' }
        ]
      },
      {
        path: 'work', component: WorkComponent, children: [
          { path: 'order', component: WorkOrderComponent },
          { path: 'submit', component: WorkOrderAddComponent },
          { path: '', redirectTo: '/main/work/order', pathMatch: 'full' }
        ]
      },
      { path: 'page-editor', component: PageEditorComponent },
      { path: 'page-editor/:id', component: PageEditorDetailComponent },
      { path: 'collect-platform', component: CollectPlatformComponent },
      { path: '', redirectTo: '/main/index', pathMatch: 'full' }
    ]
  },
  { path: '', redirectTo: '/login', pathMatch: 'full' }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
